unit TestImpl;

interface

uses
  ComObj, ActiveX, Graphics, Srv_TLB;

type
  TAutoTest = class(TAutoObject, IAutoTest)
  protected
    procedure ShowInfo; safecall;

    function Get_EditText: WideString; safecall;
    function Get_ShapeColor: OLE_COLOR; safecall;
    function Get_ShapeType: TxShapeType; safecall;

    procedure Set_EditText(const Value: WideString); 
                                                                                     safecall;
    procedure Set_ShapeColor(ShapeColor: OLE_COLOR); 
                                                                                    safecall;
    procedure Set_ShapeType(Value: TxShapeType); 
                                                                                    safecall;
  end;

implementation

uses SysUtils, ComServ, ExtCtrls, ServMain, 
          TypInfo, Dialogs;

function TAutoTest.Get_EditText: WideString;
begin
  Result := AutoTestForm.Edit1.Text;
end;

function TAutoTest.Get_ShapeType: TxShapeType;
begin
  Result := TxShapeType(AutoTestForm.Shape1.Shape);
end;

procedure TAutoTest.Set_EditText(const 
                                                    Value: WideString);
begin
  AutoTestForm.Edit1.Text := Value;
end;

procedure TAutoTest.Set_ShapeType(Value: TxShapeType);
begin
  AutoTestForm.Shape1.Shape := TShapeType(Value);
end;

function TAutoTest.Get_ShapeColor: OLE_COLOR;
begin
  Result := AutoTestForm.Shape1.Brush.Color;
end;

procedure TAutoTest.Set_ShapeColor(ShapeColor: 
                                                                          OLE_COLOR);
begin
  AutoTestForm.Shape1.Brush.Color := ShapeColor;
end;

procedure TAutoTest.ShowInfo;
const
  SInfoStr = 'The Shape''s color is %s, and it''s 
                         shape is %s.'#13#10 +   'The Edit''s text 
                         is "%s."';
begin
  with AutoTestForm do
    ShowMessage(Format(SInfoStr, 
                                [ColorToString(Shape1.Brush.Color),
                                GetEnumName(TypeInfo(TShapeType),                  
                                Ord(Shape1.Shape)), Edit1.Text]));
end;

initialization
  TAutoObjectFactory.Create(ComServer, 
                                                       TAutoTest, Class_AutoTest,
                                                       ciMultiInstance);
end.
